package com.whty.ws_fengx.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;


@ApiModel("Result请求响应")
@Data
public class Result<T> implements Serializable {
    private static final long serialVersionUID = 3716920782801195501L;

    @ApiModelProperty(value = "响应状态码", required = true)
    private Integer code;
    @ApiModelProperty(value = "响应数据", required = true)
    private T data;
    @ApiModelProperty(value = "响应消息")
    private String msg;

    public Result() {

    }

    public Result(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public Result(Integer code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public static Result buildFailedMessage(int code, String msg) {
        return new Result(code, null, msg);
    }
    public static Result buildSuccessMessage(Object data) {
        return new Result(Code.OK, data, null);
    }
    public static Result buildSuccessMessage(Object data, String msg) {
        return new Result(Code.OK, data, msg);
    }

}
